<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Org
 *
 * @author 耿鸿飞 <15911185633>
 */
class Sys_Org extends Model
{
    protected $table_org = "sys_org";
    /**
     * 获取全部的公司组织信息
     * @return Array
     */
    public function getAll(){
        $rs = array();
        $sql = sprintf("SELECT * FROM %s WHERE Fstatus='Yes'",$this->table_org);
        $list = $this->getResults($sql);
        if($list){
            foreach($list AS $val){
                $rs[$val['Foid']] = $val;
            }
        }
        return $rs;
    }
    /**
     * 获取一个公司或者组织的信息
     * @param Int $oid
     * @return Array
     */
    public function getOrg($oid){
        return $this->getRow(sprintf("SELECT * FROM %s WHERE Foid=%d",  $this->table_org,$oid));
    }
    /**
     * 根据一个列表得到公司或者组织的信息
     * @param Array $oids
     * @return type
     */
    public function getOrgs($oids = array()){
        $rs = array();
        if(is_array($oids)){
            if(count($oids) > 0){
                $sql = sprintf("SELECT * FROM %s WHERE Foid IN(%s)",$this->table_org,  implode(",", $oids));
                $list = $this->getResults($sql);
                if($list){
                    foreach($list AS $val){
                        $rs[$val['Foid']] = $val;
                    }
                }
            }
        }
        return $rs;
    }
}

?>
